cmake_minimum_required(VERSION 3.16)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_C_STANDARD 11)

project(msim C CXX ASM)

add_compile_options ( -Werror
  -Wall -Wextra -Winline -Winit-self -Wno-unused-function -Wno-unused-variable -Wno-unused-result
  -Wuninitialized -Wno-sequence-point -Wno-inline -Wno-unknown-pragmas
  -Woverloaded-virtual -Wno-unused-parameter -Wno-missing-field-initializers -pipe)

# Use ccache if installed
find_program (CCACHE_PROGRAM ccache)
if (CCACHE_PROGRAM)
  set_property (GLOBAL PROPERTY RULE_LAUNCH_COMPILE "${CCACHE_PROGRAM}")
  message ("-- Using ccache")
endif ()

message ("-- CMAKE_BUILD_TYPE=" ${CMAKE_BUILD_TYPE})

if (CMAKE_BUILD_TYPE MATCHES "^[Rr]elease")
    add_compile_options(-O3)
elseif (CMAKE_BUILD_TYPE MATCHES "^[Ff]ast[Dd]ebug")
    add_compile_options(-O3 -g)
elseif (CMAKE_BUILD_TYPE MATCHES "^[Dd]ebug")
    add_compile_options(-O2 -g)
else()
    message (FATAL_ERROR "Please provide a CMAKE_BUILD_TYPE: -DCMAKE_BUILD_TYPE=Release|FastDebug|Debug")
endif()

find_package(spdlog REQUIRED)
find_package(Boost 1.71.0 REQUIRED)

# add_compile_definitions(SPDLOG_ACTIVE_LEVEL=SPDLOG_LEVEL_TRACE)
# add_compile_definitions(SPDLOG_ACTIVE_LEVEL=SPDLOG_LEVEL_DEBUG)
# add_compile_definitions(SPDLOG_ACTIVE_LEVEL=SPDLOG_LEVEL_INFO)
add_compile_definitions(SPDLOG_ACTIVE_LEVEL=SPDLOG_LEVEL_ERROR)
# add_compile_definitions(SPDLOG_ACTIVE_LEVEL=SPDLOG_LEVEL_OFF)

include_directories(inc)
file(GLOB_RECURSE SOURCES "src/*.cpp" "src/*_core/*.cpp" "src/Cache/*.cpp")

add_executable(${PROJECT_NAME} ${SOURCES})
target_link_libraries(${PROJECT_NAME} PRIVATE spdlog::spdlog)